<?php


namespace app\common\service\coupon;


use app\common\facade\auth\Auth;
use app\common\service\auth\AuthAdminService;
use app\model\CouponConfig;

class CouponProductChannelService
{
    /**
     * 溢价管理----根据条件查询溢价数据（下单使用）
     * @access public
     * @param int $channel_id 产品id
     * @param int $agent_id   代理id
     */
    public function getPremiumRate(int $channel_id, int $agent_id)
    {

        $cacheKey = 'getPremiumRate' . $channel_id . $agent_id;
        $cache = cache($cacheKey);
        if ($cache) {
            return $cache;
        }

        if (empty($channel_id) && empty($agent_id)) {
            return false;
        }

        $premium_rate = (new CouponConfig)->getPremiumRate($channel_id, $agent_id);

        cache($cacheKey,$premium_rate,3);

        return $premium_rate;
    }
}